package com.aliwo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tech.powerjob.client.PowerJobClient;

/**
 * @author:xuyayuan
 * @date:2021/7/23 11:43
 * @description:加载powerjob-worker配置，进行连接
 */
@SuppressWarnings("all")
@Configuration
@EnableConfigurationProperties(PowerJobProperties.class)
public class PowerJobConfig {
    @Autowired
    private PowerJobProperties powerJobProperties;

    /**
     * 功能描述:powerjob-worker端初始化连接，使用OpenApi
     * @author xuyayuan
     * @param
     * @return tech.powerjob.client.PowerJobClient
     */
    @Bean
    public PowerJobClient getPowerJobClient() {
        return new PowerJobClient(powerJobProperties.getServerAddress(), powerJobProperties.getAppName(), powerJobProperties.getPassword());
    }
}
